import 'dart:io';

import 'package:flutter/material.dart';

class Avatar extends StatelessWidget {
  final String filePath;
  final double size;
  final String role;

  const Avatar(
      {super.key, required this.filePath, this.size = 50, this.role = 'user'});

  @override
  Widget build(BuildContext context) {
    return Container(
        width: size,
        height: size,
        decoration: BoxDecoration(
          // color: Colors.grey.withOpacity(0.1),
          borderRadius: BorderRadius.circular(size / 2),
        ),
        // 超出隐藏
        clipBehavior: Clip.none,
        child: filePath.isEmpty
            ? role == 'user'
                ? Image.asset(
                    'assets/avatar.png',
                    fit: BoxFit.cover,
                  )
                : role == 'assistant'
                    ? Image.asset(
                        'assets/deepseek_blue.png',
                        fit: BoxFit.cover,
                      )
                    : const Icon(
                        Icons.person,
                        color: Colors.grey,
                      )
            : Image.asset(
                filePath,
                fit: BoxFit.cover,
              ));
  }
}
